// created on 10/21/2005 at 9:52 PM
using System;
using CookComputing.XmlRpc;

namespace Whitemice.MOGI.RPC2 {
	/// \brief Implements IAddress
	public class Address : SubDocument, IAddress {
		/// \brief Constructor
		/// \param document An XmlRpcStruct document
		/// \param server Reference to server object	
		public Address (XmlRpcStruct document, IDocument parentDocument, string typeAbbrev, Server server) :
			base(document, parentDocument, typeAbbrev, server) {
		}
		
		public override string Name {
			get 
			{
				if (document.ContainsKey("id"))
					return MOGI.Id((string)document["id"]);
				return "Document/Address/0";
			}
		}
		
		/// \brief Accessor for the name1 value
		public string Name1 {
			get {
				if (document.ContainsKey("name1"))
					return (string)document["name1"];
				return "";
			}
			set {
				document["name1"] = value;
			}
		}

		/// \brief Accessor for the name2 value
		public string Name2 {
			get {
				if (document.ContainsKey("name2"))
					return (string)document["name2"];
				return "";
			}
			set {
				document["name2"] = value;
			}
		}
		
		/// \brief Accessor for the name3 value
		public string Name3 {
			get {
				if (document.ContainsKey("name3"))
					return (string)document["name3"];
				return "";
			}
			set {
				document["name3"] = value;
			}
		}		
			
		/// \brief Accessor for the street value
		public string Street {
			get {
				if (document.ContainsKey("street"))
					return (string)document["street"];
				return "";
			}
			set {
				document["street"] = value;
			}
		}
		
		/// \brief Accessor for the city value
		public string City {
			get {
				if (document.ContainsKey("city"))
					return (string)document["city"];
				return "";
			}
			set {
				document["city"] = value;
			}
		}
		
		/// \brief Accessor for the state value
		public string State {
			get {
				if (document.ContainsKey("state"))
					return (string)document["state"];
				return "";
			}
			set {
				document["state"] = value;
			}
		}	
		
		/// \brief Accessor for the zip value
		public string Zip {
			get {
				if (document.ContainsKey("zip"))
					return (string)document["zip"];
				return "";
			}
			set {
				document["zip"] = value;
			}
		}	
		
		/// \brief Accessor for the country value
		public string Country {
			get {
				if (document.ContainsKey("country"))
					return (string)document["country"];
				return "";
			}
			set {
				document["country"] = value;
			}
		}		
		
		public override bool Filled
		{
			get { return true; }
		}		
	}
}